package leetCode.offer54;

import java.util.ArrayList;
import java.util.List;

public class Solution1 implements Solution{

    @Override
    public int kthLargest(TreeNode root, int k) {
        List<TreeNode> treeNodeList = new ArrayList<>();
        mSearch(root,treeNodeList);
        return treeNodeList.get(k-1).val;
    }

    public void mSearch(TreeNode root, List<TreeNode> treeNodeList) {
        if(root!=null){
            mSearch(root.right,treeNodeList);
            treeNodeList.add(root);
            mSearch(root.left,treeNodeList);
        }
    }


}
